@echo off
chcp 65001
setlocal enabledelayedexpansion

set buildType=%1
set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
set /p versionName=<%~dp0version.txt
set substring=%date:~3,4%%date:~8,2%%date:~11,2%%hour%%time:~3,2%%time:~6,2%
set XCodeFileName=output_xcode_%versionName%_%substring%.zip

if "%buildType%"=="DEBUG" (
	C:/mateurp_pipline/obsutil/obsutil cp C:/mateurp_pipline/mateurp_ios/mateurp/Build/IOS/DEBUG/output_xcode.zip obs://wlops/mateurp_ios/%buildType%/%XCodeFileName%
)

if "%buildType%"=="RELEASE" (
	C:/mateurp_pipline/obsutil/obsutil cp C:/mateurp_pipline/mateurp_ios/mateurp/Build/IOS/RELEASE/output_xcode.zip obs://wlops/mateurp_ios/%buildType%/%XCodeFileName%
)

echo downloadUrl: https://wlops.obs.cn-north-4.myhuaweicloud.com/mateurp_ios/%buildType%/%XCodeFileName%
echo %XCodeFileName% upload finish
echo https://wlops.obs.cn-north-4.myhuaweicloud.com/mateurp_ios/%buildType%/%XCodeFileName% > "C:\mateurp_pipline\mateurp_ios\mateurp\Build\IOS\download_url.txt"
C:/mateurp_pipline/obsutil/obsutil cp "C:\mateurp_pipline\mateurp_ios\mateurp\Build\IOS\download_url.txt" obs://wlops/mateurp_ios/unity_framework_%versionName%.txt

set json="{\"text\":{\"content\":\"IOS打包完成,下载地址 https://wlops.obs.cn-north-4.myhuaweicloud.com/mateurp_ios/%buildType%/%XCodeFileName% \" },\"msgtype\":\"text\"}"
echo %json%
curl --ssl-no-revoke -H "Content-Type: application/json" -X POST -d !json! https://oapi.dingtalk.com/robot/send?access_token=1dd9ef311951334ba9e001f194f78c99ee8b74fff2c56b5f899c1727302f60b8
endlocal